package com.boatAnchorAssistant.service.controller.web;

import com.boatAnchorAssistant.pojo.param.expandField.*;
import com.boatAnchorAssistant.pojo.vo.expandField.*;
import com.boatAnchorAssistant.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.util.List;

/**
 * web/拓展字段
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/expandField/web")
public class ExpandFieldWebController {

    private final ExpandFieldService service;

    public ExpandFieldWebController(ExpandFieldService service) {
        this.service = service;
    }


    /**
     * 创建拓展字段
     *
     * @param param
     * @return
     */
    @PostMapping("/createExpandField")
    public ApiResult createExpandField(@RequestBody @Valid CreateExpandFieldParam param) {
        service.createExpandField(param);
        return ApiResult.ok();
    }


    /**
     * 保存拓展字段
     * @param param
     * @return
     */
    @PostMapping("/saveExpandField")
    public ApiResult saveExpandField(@RequestBody @Valid SaveExpandFieldParam param){
        service.saveExpandField(param);
        return ApiResult.ok();
    }


    /**
     * 修改拓展字段
     *
     * @param param
     */
    @PutMapping("/editExpandField")
    public ApiResult editExpandField(@RequestBody @Valid EditExpandFieldParam param) {
        service.editExpandField(param);
        return ApiResult.ok();
    }

    /**
     * 移除拓展字段
     *
     * @param id
     */
    @DeleteMapping("/removeExpandField")
    public ApiResult removeExpandField(@RequestParam("id") Long id) {
        service.removeExpandField(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用拓展字段
     *
     * @param id
     */
    @GetMapping("/enabledExpandField")
    public ApiResult enabledExpandField(@RequestParam("id") Long id) {
        service.enabledExpandField(id);
        return ApiResult.ok();
    }

    /**
     * 获取拓展字段详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getExpandField")
    public ApiResult<GetExpandFieldVo> getExpandField(@RequestParam("id") Long id) {
        GetExpandFieldVo vo = service.getExpandField(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取拓展字段列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getExpandFieldList")
    public ApiResult<PageResult<GetExpandFieldListVo>> getExpandFieldList(@RequestBody GetExpandFieldListParam param) {
        PageResult<GetExpandFieldListVo> result = service.getExpandFieldList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取拓展字段下拉列表
     *
     * @return
     */
    @PostMapping("/getExpandFieldDownList")
    public ApiResult<List<GetExpandFieldDownListVo>> getExpandFieldDownList(@RequestBody @Valid GetExpandFieldDownListParam param) {
        List<GetExpandFieldDownListVo> list = service.getExpandFieldDownList(param);
        return ApiResult.ok(list);
    }


    /**
     * 获取模块列表
     * @return
     */
    @GetMapping("/getModelList")
    public ApiResult<List<GetModelListVo>> getModelList(){
        List<GetModelListVo> list = service.getModelList();
        return ApiResult.ok(list);
    }

}

